from django.db import models

# Create your models here.

class User(models.Model):
    username = models.CharField(max_length=20)
    password = models.CharField(max_length=128)
    # 会员级别   0 -->普通用户      1 -->会员
    huiyuan = models.IntegerField(default=0)
    price = models.IntegerField(default=0)
    class Meta:
        db_table = 'user'

class YouHuiJuan(models.Model):
    man = models.IntegerField(default=0)
    jian = models.IntegerField(default=0)
    userid = models.ForeignKey(User, on_delete=models.CASCADE)
    class Meta:
        db_table = 'youhuijuan'

class Books(models.Model):
    name = models.CharField(max_length=20)
    price = models.IntegerField(default=0)
    count = models.IntegerField(default=0)
    class Meta:
        db_table = 'books'

class GouWuChe(models.Model):
    userid = models.ForeignKey(User, on_delete=models.CASCADE)
    bookid = models.ForeignKey(Books, on_delete=models.CASCADE)
    price = models.IntegerField(default=0)
    class Meta:
        db_table = 'gouwuche'













'''

生成迁移脚本: 'python manage.py makemigrations'

同步到数据库：‘python manage.py migrate’

创建管理员用户：‘python manage.py createsuperuser’

反   向   迁   移：python manage.py inspectdb > mymodels.py
'''

